from django.db import models


class PType(models.Model):
	name = models.CharField(max_length=25)

	def __str__(self):
		return self.name


class Player(models.Model):
	user_name = models.CharField(max_length=51, verbose_name='Псевдонім порушника', unique=True)

	def __str__(self):
		return self.user_name


class Penalty(models.Model):
	user = models.ForeignKey(Player, on_delete=models.CASCADE, verbose_name='Порушник')
	reason = models.TextField(verbose_name='Причина')
	p_type = models.ForeignKey(PType, on_delete=models.CASCADE, verbose_name='Покарання')

	class Meta:
		ordering = ['-id']

	def __str__(self):
		return "{} {}".format(self.p_type, self.user.user_name)